/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

import java.util.HashMap;
import java.util.Map;
import tree.Context;

/**
 *
 * @author adam
 */
public class ContextImplString implements Context {
    
    private int nextLabel = 1;

    private Map<String, Object> attrs = new HashMap<String, Object>();

    private String out="";
    
    public void print(String msg) {
        out=getOut().concat(msg);
    }

    public void println(String msg) {
        out=getOut().concat(msg);
        out=getOut().concat("\n");
    }

    public void printf(String format, Object... args) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

     public String nextLabel() {
        String s = "lab" + nextLabel;
        nextLabel++;
        return s;
    }

    public void addAttr(String n, Object v) {
        attrs.put(n, v);
    }

    public Object getAttr(String n) {
        return attrs.get(n);
    }

    public void removeAttr(String n) {
        attrs.remove(n);
    }

    /**
     * @return the out
     */
    public String getOut() {
        return out;
    }
    
}
